package loja.model.conta.operacao;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("O")
@Table(name = "operacao")
public class Operacao implements Cloneable, Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue
	private Long idOperacao;
	private String historico;
	private BigDecimal valor;
	private Date data = new Date();

	public Operacao() {
	}

	public Operacao(String historico, BigDecimal valor) {
		this.historico = historico;
		this.valor = valor;
	}

	public Long getIdOperacao() {
		return idOperacao;
	}

	public String getHistorico() {
		return historico;
	}

	public void setHistorico(String historico) {
		this.historico = historico;
	}

	public BigDecimal getValor() {
		return valor;
	}

	public void setValor(BigDecimal valor) {
		this.valor = valor;
	}

	public Date getData() {
		return data;
	}

	private void setData(Date data) {
		this.data = data;
	}

	@Override
	public Object clone() {
		Operacao operacao = new Operacao(this.historico, this.valor);
		operacao.setData(this.data);
		return operacao;
	}
}
